<template>
    <div class='zhuanti'>
        <div v-for='item in dataArr' :key='item.id' class='each'>
            <img :src="item.scene_pic_url" alt="">
            <p class='title'>{{item.title}}</p>
            <p class='tip'>{{item.subtitle}}</p>
            <p class='price' v-if="item.price_info">￥{{item.price_info}}元起</p>
        </div>
        <!-- 分页组件 -->
        <van-pagination v-model="page" :page-count="2" mode="simple" @change='changeFn' />
    </div>
</template>

<script>
// 引入接口
import {specialData} from '@/api/special.js'
// // 引入分页组件
// import Vue from 'vue';
// import { Pagination } from 'vant';
// Vue.use(Pagination);//相当于注册
    export default {
        name:'',
        data () {
            return {
                page:1,//当前页
                size:10,//每页的数据条数
                dataArr:[]//渲染的数据
            }
        },
        mounted(){
            this.getData()  //初始渲染
        },
        components:{
        },
        methods:{
            getData(){//初始时page传1
                specialData({page:1,size:this.size}).then(res=>{
                    this.dataArr = res.data.data.data
                })
            },
            changeFn(){
                specialData({page:this.page,size:this.size}).then(res=>{
                    this.dataArr = res.data.data.data
                    document.documentElement.scrollTop = 0;//返回顶部
                })
            }
        }
    }
</script>

<style scoped lang='less'>
.each{
    width: 100%;
    height: 350px;
    margin-bottom: 20px;
    img{
        width: 100%;
        height: 208px;
    };
    .title{
        font-size: 18px;
        text-align: center;
        margin: 10px 0 10px 0;
    };
    .tip{
        width: 370px;
        font-size: 16px;
        text-align: center;
        margin: 20px 0 20px 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    };
    .price{
        font-size: 16px;
        color: red;
        text-align: center;
    }
}
ul{
    width: 100%;
    height: 140px;
    display: flex;
    justify-content: space-between;
    margin-bottom: 100px;
    li{
        width: 50%;
        height: 40px;
        text-align: center;
        line-height: 40px;
        font-size: 14px;
        border: 1px solid black;
        .buttom{
            display: block;
            width: 187px;
            height: 42px;
        }
    };
    
}
</style>